<?php 
header("content-type:text/html;charset=utf-8");  
header('Access-Control-Allow-Origin:*');//解决跨域问题  


$code=$_GET['code'];
//echo "登录凭证：".$code;
//echo "<br>";
$appid="------------------------------------";
$appsecret="---------------------------------";
$get_url="https://api.weixin.qq.com/sns/jscode2session?appid=".$appid."&secret=".$appsecret."&js_code=".$code."&grant_type=authorization_code";
$get_return = file_get_contents($get_url);
$get_return = (array)json_decode($get_return);
$openid=$get_return['openid'];
echo $openid;
//echo "<br>";
//echo json_encode($get_return);





